#!/usr/bin/env python
"""
xml parser
"""
import xml.dom.minidom
import sys
import string
import logging

tag_project_config = 'project-config'
tag_name = 'name'
tag_description = 'description'
tag_create_date = 'create-date'
tag_last_date = 'last-date'
tag_status = 'status'
tag_creator_name = 'creator-name'
tag_creator_email = 'creator-email'
tag_log_file = 'log-file'

class XmlConfig:
    def parse(self, filePath):
        self.filePath = filePath
        self.xmlDoc =  xml.dom.minidom.parse(self.filePath)
        if self.xmlDoc == None:
            login.err("fail to open %s" % self.filePath)
        
        #read the base information of project configuration
        root = self.xmlDoc.getElementsByTagName(tag_project_config)
        if root:
            self.parseBaseConfig(root)
            self.parseSCM(root)
            self.parseSchedules(root)
        self.xmlDoc.close()

    def parseBaseConfig(self,n):
        for c in n.childNodes:
            print c.firstChild.data
        
    def parseSCM(self,n):
        pass
    def parseSchedules(self,n):
        pass
            
if __name__ == '__main__':
    f = XmlConfig()
    f.parse('demo/build.xml')
    
